{% extends "base/layui_base.html" %}

{% block title %}
	{{ super() }}
	{{ Fdata.titleAll }}
{% endblock %}

{% block main %}
<div class="layui-row" style="padding:0px 15px;">

	<button type="button" class="layui-btn" id="test1">
	  <i class="layui-icon">&#xe67c;</i>上传传真文件
	</button>
  	<button type="button" class="layui-btn" id="test7">开始上传</button>
	<hr>

	<div class="layui-row" style="padding:0px 15px 0px 15px;">
		<form class="layui-form" action="">
		  <div class="layui-form-item">
		    <label class="layui-form-label">传真主题</label>
		    <div class="layui-input-block">
		      <input type="text" name="title" required  lay-verify="required" placeholder="请输入传真主题" autocomplete="off" class="layui-input">
		    </div>
		  </div>

		  <div class="layui-form-item layui-row" >
		  	<div class="layui-inline">
			    <label class="layui-form-label">区号</label>
			    <div class="layui-input-block">
			      <input type="text" name="ldc" required  lay-verify="required" placeholder="0755" autocomplete="off" value="0755" class="layui-input">
			    </div>
		    </div>
		  	<div class="layui-inline">
			    <label class="layui-form-label">电话</label>
			    <div class="layui-input-block">
			      <input type="text" name="fax" required  lay-verify="required" value="83235170" autocomplete="off" class="layui-input">
			    </div>
		    </div>
		  </div>

		  <div class="layui-form-item">
		    <label class="layui-form-label">傲发账号</label>
		    <div class="layui-input-block">
		      <input type="text" name="account" required  placeholder="傲发帐号（发送即时传真时必填，如AF90000099）" autocomplete="off" class="layui-input">
		    </div>
		  </div>

		  <div class="layui-form-item" >
		  	<div class="layui-inline">
			    <label class="layui-form-label">发送人1</label>
			    <div class="layui-input-block">
			      <input type="text" name="sender1" required  placeholder="发件人1，标识传真发件人，如公司名" autocomplete="off" class="layui-input">
			    </div>
		    </div>
		  	<div class="layui-inline">
			    <label class="layui-form-label">发送人2</label>
			    <div class="layui-input-block">
			      <input type="text" name="sender2" required  placeholder="发件人2，标识传真发件人，如人名等" autocomplete="off" class="layui-input">
			    </div>
		    </div>
		  </div>

		  <div class="layui-form-item" >
		  	<div class="layui-inline">
			    <label class="layui-form-label">收件人1</label>
			    <div class="layui-input-block">
			      <input type="text" name="receiver1" required placeholder="收件人1，标识传真收件人，如公司名" autocomplete="off" class="layui-input">
			    </div>
		    </div>
		  	<div class="layui-inline">
			    <label class="layui-form-label">收件人2</label>
			    <div class="layui-input-block">
			      <input type="text" name="receiver2" required placeholder="收件人2，标识传真收件人，如人名等" autocomplete="off" class="layui-input">
			    </div>
		    </div>
		  </div>

		  <div class="layui-form-item">
		    <label class="layui-form-label">发送标志</label>
		    <div class="layui-input-block">
		      <input type="radio" name="sendflag" value="0" title="普通发送" checked>
		      <input type="radio" name="sendflag" value="1" title="优先发送(排到队列的首部)" >
		    </div>
		  </div>

		  <div class="layui-form-item">
		    <label class="layui-form-label">选择线路</label>
		    <div class="layui-input-block">
		      <input type="radio" name="line" value="0" title="自动调度" checked>
		      <input type="radio" name="line" value="1" title="仅电话线发送,fax不能为空" >
		      <input type="radio" name="line" value="2" title="仅即时传真发送" >
		    </div>
		  </div>

		  <div class="layui-form-item">
		    <div class="layui-input-block">
		      <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
		      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
		    </div>
		  </div>
		</form>
	</div>

</div>
{% endblock %}

{% block js %}
<script>

layui.use(['form','common','layer','upload'], function(){
  var common = layui.common
  ,upload = layui.upload
  ,layer = layui.layer

  //待发送数据
  var sendData={'sendfile':'','formData':{}}

  //执行实例
  var uploadInst = upload.render({
    elem: '#test1' //绑定元素
    ,auto: false
    ,url: '/faxUpload.html' //上传接口
    ,done: function(res){
    	console.log(res);
    	layer.msg(res.msg)
    	sendData.sendfile=res.msg
    }
    ,accept:'file'
    ,seize:1000
    ,bindAction: '#test7'
    ,error: function(){
      //请求异常回调
    }
  });

  var form = layui.form;
  
  //监听提交
  form.on('submit(formDemo)', function(data){
  	sendData.formData=data.field
    layer.msg(JSON.stringify(sendData));

	common.ajax(
		'/faxSend.html'
		,sendData
		,function(res){
		    layer.msg(JSON.stringify(res));
		}
	 );
	console.log(sendData.formData.title)	
    return false;
  });

});

</script>
{% endblock %}
